<template>
  <Editor :value="value" :plugins="plugins" @change="handleChange" />
</template>

<script setup lang="ts">
import gfm from "@bytemd/plugin-gfm";
import { Editor } from "@bytemd/vue-next";
import highlight from "@bytemd/plugin-highlight";
import { ref, defineProps, withDefaults } from "vue";
const plugins = [
  gfm(),
  highlight(),
  // Add more plugins here
];
const value = ref("");
const handleChange = (v: string) => {
  value.value = v;
};

interface Props {
  value: string;
  handleChange: (v: string) => void;
}
//withDefaults为defineProps 定义的 Props 提供默认值

const props = withDefaults(defineProps<Props>(), {
  value: () => "",
  handleChange: (v: string) => {
    console.log(v);
  },
});
</script>
